package com.springboot.scheduled.task;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 * 定时任务的相关配置
 */
//@EnableAsync // 启用并行功能
//@EnableScheduling // 启用Spring Schedule 定时任务
//@Configuration
public class TaskConfig {

    @Bean
    public TaskScheduler taskScheduler() {
        // 创建定时任务池
        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
        taskScheduler.setPoolSize(10);// 默认值为 1， 所以需要明确设置大小
        return taskScheduler;
    }
}
